//==================================================================
//  Copyright (C) 2006-2007  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
///
///
///
///
///
//==================================================================

#ifndef FONTUNI_H
#define FONTUNI_H

#include <windows.h>
#include <stdarg.h>
#include "psys.h"

class FontUni
{
	BITMAPINFO	_bmi;
	HBITMAP		_hbmp;
	HDC			_hdc;
	void		*_datap;
	u_char		*_data_outtexp;
	HFONT		_hfont;
	u_int		_tx_id;
	int			_font_he;
	int			_tail_he;	// $$$ should be properly queried from the font !!!

public:
	FontUni( u_int font_size=10 );

	void puts( const TCHAR *strp );
	void vprintf( const TCHAR *strp, va_list valist );
	void printf( const TCHAR *strp, ... );
	void puts_pos_ba( const PSYS::RectF &in_rect, int align_x, int align_y, const TCHAR *strp );
	void printf_pos_ba( const PSYS::RectF &in_rect, int align_x, int align_y, const TCHAR *strp, ... );

	int TextHeight();
	int StringWidth( const TCHAR *strp );

	void DrawBegin();
	void DrawEnd();

private:
	void allocOffscreen( u_int w, u_int h );
	void createTexture( u_int w, u_int h );
	int calc_y( int y0, int h, int align_y );
};

#endif
